package org.example.Service;

import org.example.Dao.ProductDao;
import org.example.Entity.Product;

import java.util.List;

/**
 * 实现了产品服务接口的具体类，用于处理产品信息的业务逻辑。
 */
public class ProductServiceImp implements ProductService {
    private final ProductDao productDao;

    public ProductServiceImp(ProductDao productDao) {
        this.productDao = productDao;
    }

    @Override
    public void addProduct(Product product) {
        productDao.addProduct(product);
    }

    @Override
    public List<Product> getAllProducts() {
        return productDao.getAllProducts();
    }

    @Override
    public Product getProductById(String id) {
        return productDao.getProductById(id);
    }

    @Override
    public Product getProductByName(String name) {
        return productDao.getProductByName(name);
    }

    @Override
    public List<Product> getProductsByPriceRange(double minPrice, double maxPrice) {
        return productDao.getProductsByPriceRange(minPrice, maxPrice);
    }

    @Override
    public void deleteProductById(String id) {
        productDao.deleteProductById(id);
    }

    @Override
    public void updateProductName(String id, String newName) {
        productDao.updateProductName(id, newName);
    }

    @Override
    public void updateProductPrice(String id, double newPrice) {
        productDao.updateProductPrice(id, newPrice);
    }

    @Override
    public void updateProductStockQuantity(String id, int newStockQuantity) {
        productDao.updateProductStockQuantity(id, newStockQuantity);
    }
}
